package com.dense.kuiniu.floatcabinet.mvp.model;

import com.dense.kuiniu.floatcabinet.mvp.contract.AdminContract;
import com.dense.kuiniu.floatcabinet.mvp.manager.bord.Door;
import com.dense.kuiniu.floatcabinet.mvp.manager.bord.DoorManager;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import java.util.List;

import io.reactivex.Observable;

/**
 * @author Administrator
 * @date 2020/11/6
 */
public class AdminModel extends BaseModel implements AdminContract.Model {

    public AdminModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    public Observable<List<Door>> query() {
        return Observable.create(emitter -> {
            List<Door> list = DoorManager.getInstance().getAllDoorList();
            if (!list.isEmpty()) {
                list.add(2, new Door(-1) {
                    @Override
                    public int getItemType() {
                        return 2;
                    }
                });
            }
            emitter.onNext(list);
        });
    }


}